file(GLOB SOURCES *.c)

if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
  add_custom_command(OUTPUT configure
    COMMAND sh
    ARGS autogen.sh
    DEPENDS autogen.sh
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    VERBATIM)
  add_custom_command(OUTPUT config.h
    COMMAND sh
    ARGS configure
    DEPENDS configure
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    VERBATIM)
endif()

add_library(jsonc SHARED ${SOURCES} config.h)
install(TARGETS jsonc LIBRARY DESTINATION /usr/lib64)
